package za.org.jcicada.syshealth;

import java.net.URI;
import java.util.HashMap;

import za.org.jcicada.genss.sensor.ISensorSubject;
import za.org.jcicada.genss.sensor.impl.SensorSubjectProxy;

public class SensorURISubjectCache extends HashMap<URI, ISensorSubject> {

	private static final long serialVersionUID = 1L;
	
	private static final SensorURISubjectCache instance = new SensorURISubjectCache();
	
	public static SensorURISubjectCache getInstance() {
		return instance;
	}
	
	private SensorURISubjectCache() {
		
	}

	public ISensorSubject getSensorSubject(URI uri) {
		ISensorSubject sensorSubject = get(uri);
		if (sensorSubject == null) {
			sensorSubject = new SensorSubjectProxy(uri);
			put(uri, sensorSubject);
		}
		return sensorSubject;
	}

}
